package org.jeecg.modules.bigdataanalysis.summaryanalysis.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.bigdataanalysis.summaryanalysis.vo.RqReferenceVo;
import org.jeecg.modules.bigdataanalysis.wateranalysis.vo.RqAnalysisVo;
import org.jeecg.modules.earlywarning.information.service.IEwInformationService;
import org.jeecg.modules.earlywarning.rules.entity.EwRules;
import org.jeecg.modules.earlywarning.rules.service.IEwRulesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 水能源分析
 * @Author: 贾送兵
 * @Date:   2021-11-30
 * @Version: V1.0
 */
@Api(tags="大数据分析")
@RestController
@RequestMapping("/summaryAnalysis")
@Slf4j
public class SummaryAnalysisController extends JeecgController<EwRules, IEwRulesService> {
	@Autowired
	private IEwInformationService ewInformationService;//预警


	@AutoLog(value = "屠宰数量分析")
	@ApiOperation(value="屠宰数量分析", notes="屠宰数量分析")
	@GetMapping(value = "/querye")
	public Result<?> queryeBycode(HttpServletRequest req) {

		RqReferenceVo s = new RqReferenceVo();
		RqReferenceVo d = new RqReferenceVo();
		RqReferenceVo zq = new RqReferenceVo();
		RqReferenceVo rq = new RqReferenceVo();
		s.setCkNum("0.55");
		s.setSjzNum("0.66");
		s.setCkNum("0.52");
		s.setSjzNum("0.46");
		s.setCkNum("0.55");
		s.setSjzNum("0.26");
		s.setCkNum("0.75");
		s.setSjzNum("0.56");


		d.setCkNum("0.55");
		d.setSjzNum("0.66");
		d.setCkNum("0.52");
		d.setSjzNum("0.46");
		d.setCkNum("0.55");
		d.setSjzNum("0.26");
		d.setCkNum("0.75");
		d.setSjzNum("0.56");


		zq.setCkNum("0.55");
		zq.setSjzNum("0.66");
		zq.setCkNum("0.52");
		zq.setSjzNum("0.46");
		zq.setCkNum("0.55");
		zq.setSjzNum("0.26");
		zq.setCkNum("0.75");
		zq.setSjzNum("0.56");

		rq.setCkNum("0.55");
		rq.setSjzNum("0.66");
		rq.setCkNum("0.52");
		rq.setSjzNum("0.46");
		rq.setCkNum("0.55");
		rq.setSjzNum("0.26");
		rq.setCkNum("0.75");
		rq.setSjzNum("0.56");
/*************************************以上为挡板数据******************************************/
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("today","1356");//今日
		map.put("yesterday","1200");//昨日
		map.put("thismonth","3000");//本月
		map.put("lastmonth","2800");//上月
		map.put("sRe",s);//水产出
		map.put("dRe",d);//点产出
		map.put("zqRe",zq);//蒸汽
		map.put("rqRe",rq);//燃气

		return  Result.OK(map);
	}

	@AutoLog(value = "能耗分析")
	@ApiOperation(value="能耗分析", notes="能耗分析")
	@GetMapping(value = "/analysysList")
	public Result<?> analysysList(HttpServletRequest req,@RequestParam(name = "warningTime_begin") String warningTimeBegin,
								  @RequestParam(name = "warningTime_end") String warningTimeEnd) {




		List<RqAnalysisVo> sConsume = new ArrayList<>();
		List<RqAnalysisVo> dConsume = new ArrayList<>();
		List<RqAnalysisVo> zqConsume = new ArrayList<>();
		List<RqAnalysisVo> rqConsume = new ArrayList<>();
		for (int i = 1; i < 5; i++) {
			for (int j = 1; j < 8; j++) {
				RqAnalysisVo svo = new RqAnalysisVo();
				svo.setDate("2021-10-"+j);//日期
				svo.setTotalCost("1000"+j);//总计费用
				svo.setEnergyNum("1000"+j);//能源使用量
				svo.setYieldNum("1000"+j);//产量
				svo.setAverageCost("1"+j);//费用均耗
				svo.setAverageEnergy("0.001"+j);//能源均耗
				svo.setTbNum("10.5%");//同比
				if((j&1)==1){
					svo.setState("1");//1是上涨，2是下跌
				}else{
					svo.setState("2");//1是上涨，2是下跌
				}
				if (i==1){sConsume.add(svo);}
				if (i==2){dConsume.add(svo);}
				if (i==3){zqConsume.add(svo);}
				if (i==4){rqConsume.add(svo);}
			}
		}




		Map<String,Object> map = new HashMap<String,Object>();
		map.put("sConsume",sConsume);//水能耗分析
		map.put("dConsume",dConsume);//电能耗分析
		map.put("zqConsume",zqConsume);//蒸汽能耗分析
		map.put("rqConsume",rqConsume);//燃气能耗分析

		return  Result.OK(map);
	}





}
